﻿using IcicleFramework.Components.Health;
using IcicleFramework.Entities;
using IcicleFramework.GameServices;

namespace ExampleGame.Components.Score
{
    public class PointsOnBlockDeathComponent : PointsOnDeathComponent, IPointsComponent
    {
        protected IGameObjectManager manager;

        public override void Initialize()
        {
            manager = GameServiceManager.GetService<IGameObjectManager>();
            base.Initialize();
        }

        public override void OnHealthDepleted(IHealthComponent sender, IGameObject damageInitiator)
        {
            IGameObject playerPaddle = manager.FindWithMetadata("player");

            if (playerPaddle != null)
                OnAddPoints(playerPaddle);
        }
    }
}
